<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>Document</title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
	<style type="text/css">
		.mui-grid-view.mui-grid-9 .mui-table-view-cell {
			margin: 0px;
			padding: 6px 10px;
			vertical-align: top;
			border-right: 0px solid #eee;
			border-bottom: 0px solid #eee;
			background-color: #ccc;
		}
		
		.single-image{
			width: 100px;
			height: 100px;
			background-color: white;
			padding: 0px;
			/* margin-right: 5px; */
		}
		
		.image-wrap{
			margin-top: 5px;
			margin-right: 5px;
			display: inline-block;
		}
		
		.mui-checkbox input[type=checkbox]:checked:before, .mui-radio input[type=radio]:checked:before {
			color: #FF4500;
		}
		
	</style>
</head>
<body>
	
<div id="pubilsh-input-id" class="mui-content">

	<div v-if='item.id == 21 || item.id == 23 || item.id == 24 || item.id == 25' class="mui-input-row" style="border-radius: 5px; margin-left: 8px;margin-right: 8px;margin-top: 10px;border-width: 1px;border-color: lightgray;border-style: solid;background-color: white;font-size: 15px;">
		<div class="mui-input-row mui-radio mui-left" style="display: inline-block;margin-top: 5px;">
			<label v-if="item.id == 21">求职</label>
			<label v-else-if="item.id == 23">我是男生</label>
			<label v-else-if="item.id == 24">我是房主</label>
			<label v-else="item.id == 25">车找人</label>
			<input name="radio" type="radio" checked>	
		</div>
		
		<div class="mui-input-row mui-radio mui-left" style="display: inline-block;">
			<label v-if="item.id == 21">招聘</label>
			<label v-else-if="item.id == 23">我是女生</label>
			<label v-else-if="item.id == 24">我要找房</label>
			<label v-else="item.id == 25">人找车</label>
			<input name="radio" type="radio">
		</div>
	</div>
	
	
	<div v-if="!is_dt_type(item.id)" class="mui-input-row" style="margin-left: 8px;margin-right: 8px;margin-top: 10px;" v-cloak>
		<textarea id="text-title-id" rows="2" cols="" placeholder="请输入标题" value="" style="border-radius: 5px; font-size: 14px;margin-bottom: 0px; padding:8px 10px;"></textarea>
	</div>
	
	<div class="mui-input-row" style="margin-left: 8px;margin-right: 8px;margin-top: 10px;">
		<textarea id="text-area-id" rows="5" cols="" placeholder="请输入内容" value="" style="border-radius: 5px; font-size: 14px;margin-bottom: 0px; padding:8px 10px;"></textarea>
	</div>
	
	<div style="font-size: 14px; margin-left: 15px;margin-top: 15px;color: #666;">添加图片(可选)</div>
	<div id="image-list" style="margin-left: 10px;margin-right: 5px;margin-bottom: 66px;"></div>
	<button id="submit-button-id" type="button" class="mui-btn mui-btn-block" style="border-bottom-width: 0; background-color: #FF4500;color: white;position: fixed;bottom: 0;margin-bottom: 0;height: 50px;">发布</button>
</div>

<script src="../../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/api.js" type="text/javascript" charset="utf-8"></script>
<!-- <script src="../../js/p/tt.image.picker.js" type="text/javascript" charset="utf-8"></script> -->
<script src="../../js/p/publish.base.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/user.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/p/vue.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	//是否是首页动态类型
	function is_dt_type(type){
		var _is = (type == 10 || type == 11 || type == 12 || type == 13);
		return _is;
	}
	
	mui.plusReady(function () {
	var web = plus.webview.currentWebview();
	var item = web.itemType;
	var uid = getLoginUid();
	
	web.setStyle({
		titleNView:{
		'titletext': item['title'],
		}
	});
	
	var input_v = new Vue({
		el:'#pubilsh-input-id',
		data:{
			item:{}
		}
	})
	
	input_v.item = item;
	
	 
	//初始添加按钮
	appendLastAddImage(document.getElementById('image-list'));
	
	//获取输入框
	var _textarea = document.getElementById('text-area-id');

	//提交按钮事件
	document.getElementById('submit-button-id').addEventListener('tap',function(){
		if(!userHasLogined()){
			mui.alert('只有登录后才能发布!' ,'' ,'知道了');return;
		}
		
		var item_id = item['id'];
		var d = {"uid":uid, "type":item_id};

		//动态内容
		var msg = _textarea.value;
		if(msg == null || msg.length < 1){plus.nativeUI.alert('输入内容不能为空!');return;}
		if(is_dt_type(item_id)){//动态
			d["content"] = msg;
		}else{//话题,生活服务
			var _pubtitle = document.getElementById('text-title-id');
			var _ptitle = _pubtitle.value;
			if(isEmpty(_ptitle)){plus.nativeUI.alert('标题不能为空!');return;}
			
			var _msg = {'title':_ptitle , 'content':msg};
			
			//求职招聘,交友,房屋,打车
			if(item_id == 21 || item_id == 23 || item_id == 24 || item_id == 25){
				var arrRadios = document.getElementsByTagName('input');
				_msg['type']  = arrRadios[0].checked ? 0 : 1;
			}
			
			var jsonStr = JSON.stringify(_msg);
			d['content'] = jsonStr;
		}
		
		submitToServer(publish_url , d);
	} , false);


	function isEmpty(str){
		return (str == null || str.length < 1);
	}
});
</script>
</body>
</html>